
const defaultState = {
    name:"张三丰",
    value:"默认值",
    list:[
        "好好学习",
        "天天向上"
    ],
    newsList:[]
}

function reducer(state=defaultState,action){

    if(action.type==="changeValue"){
        const newState = JSON.parse(JSON.stringify(state));
        newState.value = action.value
        console.log(action.value)
        return newState
    }else if (action.type==="changeList"){
        const content = JSON.parse(JSON.stringify(state));
        content.list = action.list.concat()
        return content

        // return {
        //     ...state,
        //     list: action.list
        // }
    }else if(action.type==="newsList"){
        // const content = JSON.parse(JSON.stringify(state));
        //     content.newsList = action.list.concat()
        // return content
        return {
            ...state,
            newsList: action.list
        }
    }

    return state

}
export default reducer